from django import forms

from user.models import CommentModel


class LoginForm(forms.Form):
    email = forms.EmailField(required=True, label="邮箱",
                             widget=forms.EmailInput(attrs={
                                 'class': 'layui-input',
                                 'id': 'L_email',
                                 'lay-verify': 'required|email',
                                 'autocomplete': 'off'
                             }))
    password = forms.CharField(required=True, label="密码",
                               widget=forms.PasswordInput(
                                  attrs={
                                      'id': 'L_pass',
                                      'lay-verify': 'required',
                                      'autocomplete': 'off',
                                      'class': 'layui-input'
                                  }
                               ))
    ver_code = forms.CharField(required=True, label="验证码",
                               widget=forms.NumberInput(attrs={
                                   'id': 'L_vercode',
                                   'lay-verify': 'required',
                                   'autocomplete': 'off',
                                   'class': 'layui-input',
                                   'placeholder': '请回答后面的问题'
                               }))


class RegisterForm(forms.Form):
    """用于验证表单填写正确的简单类"""
    email = forms.EmailField(required=True)
    username = forms.CharField(required=True)
    password = forms.CharField(required=True, widget=forms.PasswordInput)
    re_password = forms.CharField(required=True, widget=forms.PasswordInput)
    ver_code = forms.CharField(required=True, widget=forms.NumberInput)


class SettingForm(forms.Form):
    """用户基本设置信息"""
    username = forms.CharField(required=True)
    sex = forms.ChoiceField((('male', '男性'), ('female', '女性')), required=False)
    city = forms.CharField(required=False)
    desc = forms.CharField(required=False)


class RepassForm(forms.Form):
    nowpassword = forms.CharField(required=True)
    password = forms.CharField(required=True)
    repassword = forms.CharField(required=True)


class CommentForm(forms.ModelForm):
    class Meta:
        model = CommentModel
        fields = ('content',)
